/*   1:    */ package org.intellij.lang.regexp;
/*   2:    */ 
/*   3:    */

import com.intellij.codeInsight.TailType;
import com.intellij.codeInsight.completion.*;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.codeInsight.lookup.TailTypeDecorator;
import com.intellij.patterns.PlatformPatterns;
import com.intellij.patterns.PsiElementPattern;
import com.intellij.patterns.PsiElementPattern.Capture;
import com.intellij.util.PlatformIcons;
import com.intellij.util.ProcessingContext;
import com.intellij.util.ui.EmptyIcon;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */
/*  10:    */
/*  11:    */
/*  12:    */
/*  13:    */
/*  14:    */
/*  15:    */
/*  16:    */
/*  17:    */
/*  18:    */
/*  19:    */
/*  20:    */
/*  21:    */ 
/*  22:    */ public final class RegExpCompletionContributor
/*  23:    */   extends CompletionContributor
/*  24:    */ {
/*  25: 39 */   private static final Icon a = new EmptyIcon(PlatformIcons.PROPERTY_ICON.getIconWidth(), PlatformIcons.PROPERTY_ICON.getIconHeight());
/*  26:    */   
/*  27:    */   public RegExpCompletionContributor()
/*  28:    */   {
/*  29: 43 */     extend(CompletionType.BASIC, PlatformPatterns.psiElement().withText("\\I"), new CharacterClassesNameCompletionProvider(null));
/*  30:    */     
/*  31: 45 */     PsiElementPattern localPsiElementPattern1 = PlatformPatterns.psiElement().withText("\\p");
/*  32: 46 */     extend(CompletionType.BASIC, PlatformPatterns.psiElement().afterLeaf(localPsiElementPattern1), new PropertyCompletionProvider(null));
/*  33:    */     
/*  34: 48 */     PsiElementPattern localPsiElementPattern2 = PlatformPatterns.psiElement().afterLeaf(((PsiElementPattern.Capture)PlatformPatterns.psiElement().withText("{")).afterLeaf(localPsiElementPattern1));
/*  35: 49 */     extend(CompletionType.BASIC, localPsiElementPattern2, new PropertyNameCompletionProvider(null));
/*  36:    */     
/*  37:    */ 
/*  38:    */ 
/*  39:    */ 
/*  40: 54 */     localPsiElementPattern1 = PlatformPatterns.psiElement().withText("\\\\I");
/*  41: 55 */     extend(CompletionType.BASIC, localPsiElementPattern1, new CharacterClassesNameCompletionProvider(null));
/*  42:    */     
/*  43: 57 */     localPsiElementPattern2 = PlatformPatterns.psiElement().withText("\\\\p");
/*  44: 58 */     extend(CompletionType.BASIC, PlatformPatterns.psiElement().afterLeaf(localPsiElementPattern2), new PropertyCompletionProvider(null));
/*  45:    */     
/*  46: 60 */     PsiElementPattern localPsiElementPattern3 = PlatformPatterns.psiElement().afterLeaf(((PsiElementPattern.Capture)PlatformPatterns.psiElement().withText("{")).afterLeaf(localPsiElementPattern2));
/*  47:    */     
/*  48: 62 */     extend(CompletionType.BASIC, localPsiElementPattern3, new PropertyNameCompletionProvider(null));
/*  49:    */     
/*  50:    */ 
/*  51:    */ 
/*  52:    */ 
/*  53: 67 */     localPsiElementPattern1 = PlatformPatterns.psiElement().withText("\\\\");
/*  54: 68 */     extend(CompletionType.BASIC, PlatformPatterns.psiElement().afterLeaf(localPsiElementPattern1), new CharacterClassesNameCompletionProvider(null));
/*  55:    */     
/*  56: 70 */     localPsiElementPattern2 = ((PsiElementPattern.Capture)PlatformPatterns.psiElement().withText("p")).afterLeaf(localPsiElementPattern1);
/*  57:    */     
/*  58: 72 */     extend(CompletionType.BASIC, PlatformPatterns.psiElement().afterLeaf(localPsiElementPattern2), new PropertyCompletionProvider(null));
/*  59:    */     
/*  60: 74 */     localPsiElementPattern3 = PlatformPatterns.psiElement().afterLeaf(((PsiElementPattern.Capture)PlatformPatterns.psiElement().withText("{")).afterLeaf(localPsiElementPattern2));
/*  61:    */     
/*  62: 76 */     extend(CompletionType.BASIC, localPsiElementPattern3, new PropertyNameCompletionProvider(null));
/*  63:    */   }
/*  64:    */   
/*  65:    */   private static void a(CompletionResultSet paramCompletionResultSet, @NonNls String paramString1, String paramString2, Icon paramIcon)
/*  66:    */   {
/*  67: 81 */     paramCompletionResultSet.addElement(a(paramString1, paramString2, paramIcon));
/*  68:    */   }
/*  69:    */   
/*  70:    */   private static LookupElement a(String paramString1, String paramString2, Icon paramIcon)
/*  71:    */   {
/*  72: 85 */     return LookupElementBuilder.create(paramString1).withTypeText(paramString2).withIcon(paramIcon);
/*  73:    */   }
/*  74:    */   
/*  75:    */   private static class PropertyNameCompletionProvider
/*  76:    */     extends CompletionProvider<CompletionParameters>
/*  77:    */   {
/*  78:    */     PropertyNameCompletionProvider(RegExpCompletionContributor.0 param0)
/*  79:    */     {
/*  80: 88 */       this();
/*  81:    */     }
/*  82:    */     
/*  83:    */     public void addCompletions(@NotNull CompletionParameters paramCompletionParameters, ProcessingContext paramProcessingContext, @NotNull CompletionResultSet paramCompletionResultSet)
/*  84:    */     {
/*  85: 93 */       if (paramCompletionParameters == null) {
/*  86: 93 */         throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/lang/regexp/RegExpCompletionContributor$PropertyNameCompletionProvider", "addCompletions" }));
/*  87:    */       }
/*  88: 93 */       if (paramCompletionResultSet == null) {
/*  89: 93 */         throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "2", "org/intellij/lang/regexp/RegExpCompletionContributor$PropertyNameCompletionProvider", "addCompletions" }));
/*  90:    */       }
/*  91: 93 */       for (String[] arrayOfString1 : RegExpLanguageHosts.getInstance().getAllKnownProperties(paramCompletionParameters.getPosition())) {
/*  92: 94 */         paramCompletionResultSet.addElement(TailTypeDecorator.withTail(RegExpCompletionContributor.a(arrayOfString1[0], null, RegExpCompletionContributor.a), TailType.createSimpleTailType('}')));
/*  93:    */       }
/*  94:    */     }
/*  95:    */     
/*  96:    */     private PropertyNameCompletionProvider() {}
/*  97:    */   }
/*  98:    */   
/*  99:    */   private static class PropertyCompletionProvider
/* 100:    */     extends CompletionProvider<CompletionParameters>
/* 101:    */   {
/* 102:    */     PropertyCompletionProvider(RegExpCompletionContributor.0 param0)
/* 103:    */     {
/* 104:100 */       this();
/* 105:    */     }
/* 106:    */     
/* 107:    */     public void addCompletions(@NotNull CompletionParameters paramCompletionParameters, ProcessingContext paramProcessingContext, @NotNull CompletionResultSet paramCompletionResultSet)
/* 108:    */     {
/* 109:105 */       if (paramCompletionParameters == null) {
/* 110:105 */         throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/lang/regexp/RegExpCompletionContributor$PropertyCompletionProvider", "addCompletions" }));
/* 111:    */       }
/* 112:105 */       if (paramCompletionResultSet == null) {
/* 113:105 */         throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "2", "org/intellij/lang/regexp/RegExpCompletionContributor$PropertyCompletionProvider", "addCompletions" }));
/* 114:    */       }
/* 115:105 */       for (String[] arrayOfString1 : RegExpLanguageHosts.getInstance().getAllKnownProperties(paramCompletionParameters.getPosition())) {
/* 116:106 */         RegExpCompletionContributor.a(paramCompletionResultSet, "{" + arrayOfString1[0] + "}", arrayOfString1.length > 1 ? arrayOfString1[1] : null, PlatformIcons.PROPERTY_ICON);
/* 117:    */       }
/* 118:    */     }
/* 119:    */     
/* 120:    */     private PropertyCompletionProvider() {}
/* 121:    */   }
/* 122:    */   
/* 123:    */   private static class CharacterClassesNameCompletionProvider
/* 124:    */     extends CompletionProvider<CompletionParameters>
/* 125:    */   {
/* 126:    */     CharacterClassesNameCompletionProvider(RegExpCompletionContributor.0 param0)
/* 127:    */     {
/* 128:111 */       this();
/* 129:    */     }
/* 130:    */     
/* 131:    */     public void addCompletions(@NotNull CompletionParameters paramCompletionParameters, ProcessingContext paramProcessingContext, @NotNull CompletionResultSet paramCompletionResultSet)
/* 132:    */     {
/* 133:117 */       if (paramCompletionParameters == null) {
/* 134:117 */         throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/lang/regexp/RegExpCompletionContributor$CharacterClassesNameCompletionProvider", "addCompletions" }));
/* 135:    */       }
/* 136:117 */       if (paramCompletionResultSet == null) {
/* 137:117 */         throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "2", "org/intellij/lang/regexp/RegExpCompletionContributor$CharacterClassesNameCompletionProvider", "addCompletions" }));
/* 138:    */       }
/* 139:    */       String[] arrayOfString1;
/* 140:117 */       for (arrayOfString1 : RegExpLanguageHosts.getInstance().getKnownCharacterClasses(paramCompletionParameters.getPosition())) {
/* 141:118 */         RegExpCompletionContributor.a(paramCompletionResultSet, arrayOfString1[0], arrayOfString1[1], RegExpCompletionContributor.a);
/* 142:    */       }
/* 143:121 */       for (arrayOfString1 : RegExpLanguageHosts.getInstance().getAllKnownProperties(paramCompletionParameters.getPosition())) {
/* 144:122 */         RegExpCompletionContributor.a(paramCompletionResultSet, "p{" + arrayOfString1[0] + "}", arrayOfString1.length > 1 ? arrayOfString1[1] : null, PlatformIcons.PROPERTY_ICON);
/* 145:    */       }
/* 146:    */     }
/* 147:    */     
/* 148:    */     private CharacterClassesNameCompletionProvider() {}
/* 149:    */   }
/* 150:    */ }



/* Location:           E:\idea\

 * Qualified Name:     org.intellij.lang.regexp.RegExpCompletionContributor

 * JD-Core Version:    0.7.0.1

 */